<!DOCTYPE HTML>
<html>
<head>
<include file="Include:meta" />
<title>公告详情-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">公告 > 公告详情</div>
	</div>
	<div id="content">
		<div class="form-main">
			<div class="form-title">公告详情</div>
			<div class="form-item">
				<div width="10%" class="input-label">标题</div>
				<div class="input-item">
					{$result['title']}
				</div>
			</div>
			<div class="form-item">
				<div class="input-label">分类</div>
				<div class="input-item">
					<if condition="$result['type'] eq 1">项目制度</if>
					<if condition="$result['type'] eq 2">公司制度</if>
					<if condition="$result['type'] eq 3">信息发布</if>
					<if condition="$result['type'] eq 4">通知</if>
					<if condition="$result['type'] eq 5">其它</if>
				</div>
			</div>
			<if condition="((get_permission('GG',NULL,3)) and ($vo['add_uid'] eq $login_id)) or (get_permission('GG',NULL,1))">
				<div class="form-item">
					<div width="10%" class="input-label">针对用户</div>
					<div class="input-item">
						<if condition="$result['is_all'] eq 1">全部用户<else/>{$result['users']}</if>
					</div>
				</div>
			</if>
			<if condition="$result['attachment'] neq NULL">
			<div class="form-item">
				<div width="10%" class="input-label">附件</div>
				<div class="input-item">
					<div class="input-append">
						{$result['attachment_name']}<a href="{$result['attachment']}" target="_blank" data-toggle="tooltip" data-placement="right" title="下载" class="download-num ml5"><i class="glyphicon glyphicon-download-alt"></i></a>
					</div>
				</div>
			</div>
			</if>
			<div class="form-item">
				<div class="input-label">内容</div>
				<div class="input-item">
					{$result['content']}
				</div>
			</div>
			<div class="form-item">
				<div class="input-label">添加人(日期)</div>
				<div class="input-item">
					{$result['add_user']}({$result['add_date']|substr=0,10})
				</div>
			</div>
		</div>
		<div class="form-main">
			<div class="form-title">公告评论</div>
			<div>
				<foreach name="reply" item="vo" key="k">
					<div id="reply{$k+1}" class="reply-list">
						<div class="reply-pi">{$k+1}楼</div>
						<div class="reply-name">
							{$vo['add_user']}：
						</div>
						<div class="reply-comment">{$vo['content']}</div>
						<div class="reply-date">
							<if condition="$vo['reply_able'] eq 1">
							<a href="javascript:;" class="relpay mr5">回复</a>
							</if>
							<if condition="$vo['delete'] eq 1">
							<a href="javascript:;" class="delete red mr5" comment_id="{$vo['id']}">删除</a>
							</if>
							{$vo['add_date']}
						</div>
						<if condition="$vo['answer'] neq NULL">
							<div class="reply_content_box">
								<div class="title">回复</div>
								<div class="reply_content">
									<div class="reply-name">
										{$vo['answer']['add_user']}：
									</div>
									<div class="reply-comment">{$vo['answer']['content']}</div>
									<div class="reply-date">
										<if condition="$vo['answer']['delete'] eq 1">
											<a href="javascript:;" class="delete_reply red mr5" reply_id="{$vo['answer']['id']}">删除</a>
										</if>
										{$vo['answer']['add_date']}
									</div>
								</div>
							</div>
						</if>
						<div class="replay_blk hide">
							<strong>发表回复</strong><br />
							<textarea class="form-control replay-textarea w500 h100" autocomplete="off"></textarea>
							<br>
							<button type="button" reply_id="{$vo['id']}" class="btn reply_sub mt5">提交</button>
							<input type="button" class="btn btn-default reply_cancel mt5 ml5" value="取消">
						</div>
					</div>
				</foreach>
			</div>
			<div class="form-item">
				<div class="input-label">发表评论</div>
				<div class="input-item">
					<textarea class="form-control comment-textarea w500 h100" autocomplete="off"></textarea>
					<br>
					<button type="button" class="btn mt5 comment_btn">提交</button>
				</div>
			</div>
		</div>
	</div>
	<div class="form-btn-item"><button class="btn btn-default goback" type="button">返回</button></div>
</div>
<!--对话框-->
<div class="modal fade" id="deleteModal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>确认提示框</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">您确定要删除该评论吗？</div>
			<div class="modal-footer">
				<button type="button" class="btn del">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<div class="modal fade" id="deleteModal2">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>确认提示框</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">您确定要删除该回复吗？</div>
			<div class="modal-footer">
				<button type="button" class="btn del">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	//发表评论
	$(".comment_btn").click(function(){
		var $textarea = $(this).prevAll(".comment-textarea").eq(0),
			$val = $textarea.val(),
			$main_id = "{$result['id']}";
		if($val=="" || /^\s+$/.test($val) || $val=="请输入评论内容"){
			$textarea.val("请输入评论内容").addClass("red");
		}else{
			$.ajax({
				cache:true,
				type:"POST",
				dataType:"json",
				url:"__APP__/System/notice_list_details_ask",
				data:{"action":"comment","main_id":$main_id,"content":$val},
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	
	//取消错误提示
	$("textarea").focus(function(){
		$(this).val("").removeClass("red");
	});
	
	//删除评论
	$(".delete").click(function(){
		var comment_id = $(this).attr("comment_id");
		$("#deleteModal").find(".del").attr({"comment_id":comment_id}).end().modal();
	});
	
	$("#deleteModal").find(".del").click(function(){
		var comment_id = $(this).attr("comment_id");
		$("#deleteModal").hide();
		$.ajax({
			type:"POST",
			asnyc:true,
			dataType:"json",
			data:{"action":"delete_comment","id":comment_id},
			url:"__APP__/System/notice_list_details_ask",
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
	
	//发表回复
	$(".relpay").click(function(){
		$(this).parents(".reply-list").find(".replay_blk").slideDown();
	});
	
	$(".reply_sub").click(function(){
		var $textarea = $(this).prevAll(".replay-textarea").eq(0),
			$val = $textarea.val(),
			$main_id = "{$result['id']}",
			$reply_id = $(this).attr("reply_id");
		if($val=="" || /^\s+$/.test($val) || $val=="请输入回复内容"){
			$textarea.val("请输入回复内容").addClass("red");
		}else{
			$.ajax({
				cache:true,
				type:"POST",
				dataType:"json",
				url:"__APP__/System/notice_list_details_ask",
				data:{"action":"reply","main_id":$main_id,"reply_id":$reply_id,"content":$val},
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	
	//回复取消
	$(".reply_cancel").click(function(){
		$(this).parents(".replay_blk").slideUp();
		$(this).prevAll(".replay-textarea").eq(0).val("").removeClass("red");
	});
	
	//删除回复
	$(document).on("click",".delete_reply",function(){
		var reply_id = $(this).attr("reply_id");
		$("#deleteModal2").find(".del").attr({"reply_id":reply_id}).end().modal();
		$("#deleteModal2").modal();
	});
	
	$("#deleteModal2 .del").click(function(){
		var reply_id = $(this).attr("reply_id");
		$("#deleteModal2").hide();
		$.ajax({
			type:"POST",
			asnyc:true,
			dataType:"json",
			data:{"action":"delete_reply","id":reply_id},
			url:"__APP__/System/notice_list_details_ask",
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
});
</script>
</body>
</html>